<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('机具采购、退款列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" name="applyStatus" value="0">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">流水号：</label>
                                <input type="text" name="serial"/>
                            </li>
                            <li>
                                <label style="width: 120px;">代理商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width: 120px;">申请类型：</label>
                                <select name="type">
                                    <option value="">所有</option>
                                    <option value="0">采购</option>
                                    <option value="1">退款</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">打款人：</label>
                                <input type="text" name="dkMan"/>
                            </li>
                            <li>
                                <label style="width: 120px;">审核人：</label>
                                <input type="text" name="examineMan"/>
                            </li>
                            <li>
                                <label style="width: 120px;">添加人：</label>
                                <input type="text" name="addMan"/>
                            </li>
                            <li>
                                <label style="width: 120px;">终端类型：</label>
                                <select name="posType">
                                    <option value="">所有</option>
                                    <option value="0">传统</option>
                                    <option value="4">电签</option>
                                    <option value="5">GB传统</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">返现对象：</label>
                                <input type="text" name="returnAgent"/>
                            </li>
                            <li>
                                <label style="width: 120px;">返现奖励(元)：</label>
                                <input type="text" name="returnMoney"/>
                            </li>
                            <li>
                                <label style="width: 120px;">返现对象(团长)：</label>
                                <input type="text" name="returnAgentT"/>
                            </li>
                            <li>
                                <label style="width: 120px;">返现奖励(团长)元：</label>
                                <input type="text" name="returnMoneyT"/>
                            </li>
                            <li>
                                <label style="width: 120px;">打款方式:</label>
                                <select name="dkWay">
                                    <option value="">所有</option>
                                    <option value="1">现金</option>
                                    <option value="2">pos</option>
                                    <option value="3">网银</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 120px;">打款类型:</label>
                                <select name="rewardType">
                                    <option value="">所有</option>
                                    <option value="3">2元</option>
                                    <option value="1">4元</option>
                                    <option value="2">8元</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">添加日期：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="dkStart"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="dkEnd"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">添加日期：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="addStart"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="addEnd"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 120px;">审核时间：</label>
                                <input type="text" class="time-input"  placeholder="开始时间" name="auditStart"/>
                                <span>-</span>
                                <input type="text" class="time-input"  placeholder="结束时间" name="auditEnd"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="audit()" shiro:hasPermission="agentPosOperation:agentPosOperation:add">
                    <i class="fa fa-plus"></i> 审核
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="agentPosOperation:agentPosOperation:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="agentPosOperation:agentPosOperation:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="agentPosOperation:agentPosOperation:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('agentPosOperation:agentPosOperation:edit')}]];
        var removeFlag = [[${@permission.hasPermi('agentPosOperation:agentPosOperation:remove')}]];
        var prefix = ctx + "agentPosOperation/agentPosOperation";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "机具采购、退款",
                queryParams:queryParams,
                clickToSelect:true,
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主鍵',
                    visible:false
                },
                {
                    field: 'serial',
                    title: '流水号'
                },
                {
                    field: 'agentNum',
                    title: '代理商编号'
                },
                {
                    field: 'oneMoney',
                    title: '单终端价格'
                },
                {
                    field: 'allMoney',
                    title: '终端总价格'
                },
                {
                    field: 'num',
                    title: '终端数量'
                },
                {
                    field: 'type',
                    title: '申请类型',
                    formatter(value,row,index){
                        if (value == 0){
                            return "<span style='color: blue'>采购</span>";
                        } else if (value == 1){
                            return "<span style='color: red'>退款</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'teamType',
                    title: '团类型',
                    formatter(value,row,index){
                        if (value == '1'){
                            return "<span style='color: blue'>老团</span>";
                        } else if (value == '2'){
                            return "<span style='color: red'>新团</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'applyStatus',
                    title: '审核状态',
                    formatter(value,row,index){
                        if (value == 0){
                            return "<span style='color: blue'>待审核</span>";
                        } else if (value == 1){
                            return "<span style='color: green'>审核通过</span>";
                        } else if (value == 2){
                            return "<span style='color: red'>审核拒绝</span>";
                        } else if (value == 3){
                            return "<span style='color: red'>作废</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'imageUrl',
                    title: '打款凭证',
                    formatter: function(value, row, index) {
                        return $.table.imageView(value);
                    }
                },
                {
                    field: 'addMan',
                    title: '添加人'
                },
                {
                    field: 'addDate',
                    title: '添加日期'
                },
                {
                    field: 'examineMan',
                    title: '审核人'
                },
                {
                    field: 'examineDate',
                    title: '审核时间'
                },
              /*  {
                    field: 'isCashback',
                    title: '是否返现',
                    formatter(value,row,index){
                        if (value == 0){
                            return "<span style='color: blue'>采购-是 退款-需要扣款</span>";
                        } else if (value == 1){
                            return "<span style='color: green'>采购-否 退款-不需要</span>";
                        } else {
                            return "未知";
                        }
                    }
                },*/
              /*  {
                    field: 'cashbackMoney',
                    title: '返现金额',
                    formatter: function(value, row, index) {
                        return $.table.rmbFormatter(value);
                    }
                },*/
                {
                    field: 'posType',
                    title: '终端类型',
                    formatter(value,row,index){
                        if (value == 0){
                            return "<span style='color: blue'>传统</span>";
                        } else if (value == 4){
                            return "<span style='color: green'>电签</span>";
                        } else if (value == 5){
                            return "<span style='color: green'>GB传统</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'returnAgent',
                    title: '营销返现奖励(返现对象)'
                },
                {
                    field: 'returnMoney',
                    title: '营销返现奖励(返现金额) 元'
                },
               /* {
                    field: 'returnAgentT',
                    title: '团长返现奖励(返现对象)'
                },
                {
                    field: 'returnMoneyT',
                    title: '团长返现奖励(返现金额)元'
                },*/
                {
                    field: 'dkWay',
                    title: '打款方式',
                    formatter(value,row,index){
                        if (value == 1){
                            return "<span style='color: blue'>现金</span>";
                        } else if (value == 2){
                            return "<span style='color: green'>pos</span>";
                        } else if (value == 3){
                            return "<span style='color: green'>网银</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'rewardType',
                    title: '打款类型',
                    formatter(value,row,index){
                        if (value == '1'){
                            return "<span style='color: blue'>4元</span>";
                        } else if (value == '2'){
                            return "<span style='color: green'>8元</span>";
                        } else if (value == '3'){
                            return "<span style='color: green'>2元</span>";
                        } else {
                            return "未知";
                        }
                    }
                },
                {
                    field: 'dkDate',
                    title: '打款时间'
                },
                {
                    field: 'dkMan',
                    title: '打款人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


        /**
         * 设置查询参数
         */
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.applyStatus = '0';
            return search;
        }


        /**
         * 审核申请单
         */
        function audit() {
            var id = $.table.selectColumns("id");
            if ($.common.isEmpty(id)){
                $.modal.msgError("请选择一条数据");
                return;
            }
            $.modal.open("审核申请单",prefix + "/edit/" + id,1200,800);
        }


    </script>
</body>
</html>